package com.ruoyi.wechat.api;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.wechat.domain.Evaluate;
import com.ruoyi.wechat.service.IEvaluateService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
@Api(value = "微信小程序API-营地评价管理",tags = {"微信小程序API-营地评价管理"})
@RestController
@RequestMapping("/wechat/evaluate")
public class WxEvaluateController extends BaseController {
    @Autowired
    private IEvaluateService evaluateService;

    /**
     * 新增营地评价
     * @param evaluate
     * @return
     */
    @ApiOperation(value = "添加评论")
    @Log(title = "微信接口-营地评价",businessType = BusinessType.INSERT)
    @PostMapping("wxadd")
    public AjaxResult add(@RequestBody Evaluate evaluate){
        return  toAjax(evaluateService.insertEvaluate(evaluate));
    }

    /**
     * 查询营地评价列表
     * @param evaluate
     * @return
     */
    @ApiOperation(value = "根据营地ID查询该营地下所有评论")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "campId",value = "营地Id",required = true,
                    dataType = "String",paramType = "query")
    })
    @GetMapping("/wxList")
    public AjaxResult list(Evaluate evaluate){
        List<Evaluate> list=evaluateService.selectEvaluateList(evaluate);
        return success(list);
    }

    /**
     * 获取营地评价详细信息
     * @param evaluateId
     * @return
     */
    @ApiOperation(value = "根据评论ID查询该评论下所有评论")
    @GetMapping(value = "/wxgetInfo/{evaluateId}")
    public AjaxResult getInfo(@PathVariable("evaluateId") String evaluateId){
        return success(evaluateService.selectEvaluateByEvaluateId(evaluateId));
    }
    /**
     * 删除营地评价
     * @param evaluateId
     * @return
     */
    @ApiOperation(value = "根据评论Id删除评论")
    @Log(title = "微信接口-营地评价",businessType = BusinessType.DELETE)
    @DeleteMapping("/delete/{evaluateId}")
    public AjaxResult remove(@PathVariable String evaluateId){
        return  toAjax(evaluateService.deleteEvaluateByEvaluateId(evaluateId));
    }
}

